[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
setmode() Set File-Translation Mode
#include <io.h> Required for declarations only
#include <fcntl.h>
int setmode(handle,mode);
int handle; File handle
int mode; New translation mode
setmode() sets the translation mode of the file associated with
'handle' to 'mode'. 'mode' must be one of the following constants:
O_TEXT Text (translated) mode. In text mode,
carriage-return-line-feed combinations are translated
to a line-feed on input. The line-feed characters
are translated back to a carriage-return and
line-feed on output.
O_BINARY Set binary (untranslated) mode. The above
translations are suppressed.
setmode() is typically used to modify the default translation mode of
'stdin', 'stdout', 'stderr', 'stdaux', and 'stdprn' (standard input,
standard output, standard error, standard auxiliary, and standard
print). 'stdin', 'stdaux', and 'stderr' streams are opened in text
mode by default. 'stdaux' and 'stdprn' are opened in binary mode.
setmode() can also be used on files and can be used to change the
mode of a file after it has been opened.
Returns: Zero, if successful; On error, -1 is returned and
'errno' (defined in <errno.h>) is set to EINVAL
(Invalid 'mode' argument).
-------------------------------- Example ---------------------------------
This example sets 'stdout' to binary mode.
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
main()
{
int rslt;
if ((rslt = setmode(fileno(stdout),O_BINARY)) == 0)
printf("output file set to binary mode");
}
See Also:
creat()
fopen()
open()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson